package com.sunwayhorizo.health.business.base;

import java.util.Collection;

import com.sunwayhorizo.health.business.dto.ResultsDTO;
import com.sunwayhorizo.health.ets.factory.DictionaryFactory;
import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.datatypes.CD;
import com.sunwayhorizo.health.hl7.datatypes.CE;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.factories.ActFactory;
import com.sunwayhorizo.health.hl7.factories.DataTypeFactory;
import com.sunwayhorizo.health.hl7.factories.EntityFactory;
import com.sunwayhorizo.health.hl7.factories.RoleFactory;
import com.sunwayhorizo.health.hl7.rim.Act;
import com.sunwayhorizo.health.hl7.rim.ControlAct;
import com.sunwayhorizo.health.hl7.rim.Hl7Entity;
import com.sunwayhorizo.health.hl7.rim.Role;

public interface IBaseManager {

	public DataTypeFactory getDataTypeFactory();

	public EntityFactory getEntityFactory();

	public ActFactory getActFactory();

	public RoleFactory getRoleFactory();

	public DictionaryFactory getDictionaryFactory();

	public <T> T find(Class<T> entityClass, Object primaryKey);

	public void save(Object entity);

	public void update(Object entity);

	public void delete(Class<?> entityClass, Object primaryKey);

	public void delete(Object entity);
	
	public void batchSave(@SuppressWarnings("rawtypes") final Collection os) throws Hl7Exception;
	
	public boolean batchUpdate(@SuppressWarnings("rawtypes") final Collection os) throws Hl7Exception;

	/**
	 * 得到返回的ResultsDTO
	 * 
	 * @param resultDesc 成功与否的描述信息
	 * @param resultFlag 成功与否的标志信息(true,false)
	 * @param returnObj  返回的数据List,Object
	 * @return ResultsDTO
	 * @throws Hl7Exception
	 */
	public ResultsDTO getResultsDTO(String resultDesc, boolean resultFlag,
			Object returnObj) throws Hl7Exception;
	
	
	/**
	 * 业务保存公共方法。外部创建的Role可以跟Act建立关系
	 * @param code  act code值
	 * @param typeCode  RimCoreActPrtcptns typeCode值
	 * @param id  序列
	 * @param role 需要跟act建立关系的Role
	 * @return
	 * @throws Hl7Exception
	 */
	public ControlAct newControlAct(CD code, CS typeCode,String id,Role role) throws Hl7Exception;
	
	 /**
     * 业务中多个角色参与到一个动作用此方法进行对ControlAct的保存
     * @param act
     *            业务中需要建立关系source动作
     * @return ControlAct
     * @throws Hl7Exception
     */
    public ControlAct newControlAct(Act act) throws Hl7Exception;

}
